package com.eightbears.beboy.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eightbears.beboy.R;
import com.eightbears.beboy.entity.PayTypeEntity;

public class PaymentAdapter extends BaseQuickAdapter<PayTypeEntity, BaseViewHolder> {

    private int mPosition = -1;

    public PaymentAdapter() {
        super(R.layout.item_payment, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, PayTypeEntity payTypeEntity) {
        Glide.with(mContext).load(payTypeEntity.getCover()).into((ImageView) baseViewHolder.getView(R.id.iv_cover));
        baseViewHolder.setText(R.id.tv_name, payTypeEntity.getName())
                .setTag(R.id.ll_item, payTypeEntity.getType())
                .addOnClickListener(R.id.ll_item);
        ImageView iv_checked = baseViewHolder.getView(R.id.iv_checked);
        iv_checked.setImageResource(R.mipmap.icon_weixuan);

        if (baseViewHolder.getLayoutPosition() == mPosition) {
            iv_checked.setImageResource(R.mipmap.icon_xuanzhong);
        }
    }

    public void checked(int position) {
        mPosition = position;
        notifyDataSetChanged();
    }
}
